import { createRouter, createWebHashHistory } from 'vue-router'
//constantRouters 为静态路由不参与路由权限拦截，因此不做权限控制
import Layout from '@/layout/index.vue'
const constantRouters = [
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [
      {
        path: 'dashboard',
        name: 'Dashboard',
        component: () => import('@/views/dashboard/index.vue'),
        meta: { title: 'Dashboard' }
      }
    ]
  }
]
//asyncRoutes 为异步路由在路由拦截时参与路由拦截
export const asyncRoutes = [
  // 404 page must be placed at the end !!!
  // using pathMatch install of "*" in vue-router 4.0
  { path: '/:pathMatch(.*)', redirect: '/404', hidden: true }
]
const router = createRouter({
  //createWebHashHistory 采用路由hash模式#
  history: createWebHashHistory(),
  //每次进入页面将页面重置到顶部
  scrollBehavior: () => ({ top: 0 }),
  //将静态路由注册到路由上
  routes: constantRouters
})
